package com.isnmp.nms.framework.discover;

import java.io.Serializable;

public class LinkInfo implements Serializable {
    public DeviceInfo startDevice;
    public DeviceInfo endDevice;
    public PortInfo startPortInfo;
    public PortInfo endPortInfo;
    public int startPort = -1;
    public int endPort = -1;
    public String linkType = LinkTypeInbound;
    public static final int UnknownPort = -1;
    public static final String LinkTypeInbound = Messages.getString("LinkInfo.0");
    public static final String LinkTypeOutbound = Messages.getString("LinkInfo.1");

    public String toString() {
        return this.linkType + "," + this.startDevice + Messages.getString("LinkInfo.3") + (this.startPort == -1 ? Messages.getString("LinkInfo.4") : Integer.valueOf(this.startPort)) + ",MAC:" + this.startDevice.getDeviceMAC() + " <------> " + this.endDevice + Messages.getString("LinkInfo.7") + (this.endPort == -1 ? Messages.getString("LinkInfo.8") : Integer.valueOf(this.endPort)) + ",MAC:" + this.endDevice.getDeviceMAC();
    }

    public boolean equals(Object paramObject) {
        if ((paramObject instanceof LinkInfo)) {
            LinkInfo localLinkInfo = (LinkInfo) paramObject;
            if ((this.startDevice.equals(localLinkInfo.startDevice)) && (this.startPort == localLinkInfo.startPort) && (this.endDevice.equals(localLinkInfo.endDevice)) && (this.endPort == localLinkInfo.endPort))
                return true;
        }
        return false;
    }

    public int checkFuzzyOrAccurate(LinkInfo paramLinkInfo) {
        if (equals(paramLinkInfo))
            return 0;
        if ((paramLinkInfo.startDevice.equals(this.startDevice)) && (paramLinkInfo.endDevice.equals(this.endDevice))) {
            int i = paramLinkInfo.startPort;
            int j = paramLinkInfo.endPort;
            if ((-1 == this.startPort) && (-1 == this.endPort))
                return 1;
            if ((-1 == this.startPort) && (-1 != i) && (j == this.endPort))
                return 1;
            if ((-1 == this.endPort) && (-1 != j) && (i == this.startPort))
                return 1;
            if ((-1 == i) && (-1 == j))
                return 0;
            if ((-1 != this.startPort) && (-1 != this.endPort)) {
                if ((this.startPort == i) && (-1 == j))
                    return 0;
                if ((this.endPort == j) && (-1 == i))
                    return 0;
            }
            return -1;
        }
        return -1;
    }
}